local p=package
p.path=p.path..';D:/code/luaboost/trunk/concurrentlua/src/?/init.lua;D:/code/luaboost/trunk/concurrentlua/src/?.lua'

p.cpath=p.cpath..';D:/code/luaboost/trunk/bin/debug/?.dll'
require'concurrent';
require 'concurrent'

function pong(n)
    concurrent.register('pong', concurrent.self())
    for i = 1, n do
        local msg  = concurrent.receive()
		print(msg)
		if msg then print(msg.from[2]);end
        print('pong received message from ping')
        concurrent.send(msg.from, { from = { 'pong', 'pong@localhost' },
            body = 'pong' })
        print('pong sent reply to ping')
    end
    print('pong exiting')
    print('node(): ' .. concurrent.node())
    print('isnodealive(): ' .. tostring(concurrent.isnodealive()))
    print('nodes(): ' .. unpack(concurrent.nodes()))
end

concurrent.spawn(pong, 3)

concurrent.init('pong@localhost')
concurrent.loop()
concurrent.shutdown()
